package com.atguigu.lease.common.context;

/**
 * 工具类：用于线程数据绑定和清理
 */
public class LoginUserContext {

    private static final ThreadLocal<LoginUser> threadLocal = new ThreadLocal<>();

    //将数据绑定到线程上
    public static void setLoginUser(LoginUser loginUser) {
        threadLocal.set(loginUser);
    }

    //从线程上获取数据
    public static LoginUser getLoginUser() {
        return threadLocal.get();
    }

    //清理线程上绑定的数据
    public static void clear() {
        threadLocal.remove();
    }

}
